package ch.ethz.group3.myalbum.client;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.util.SC;

public class ImageDataSource extends DataSource {

	private static ImageDataSource instance = null;

	private ImageDataSource(String id) {
		setID(id);
		DataSourceTextField imageId = new DataSourceTextField("imageId");
		imageId.setPrimaryKey(true);
		imageId.setHidden(true);
		DataSourceTextField thumbnail = new DataSourceTextField("thumbnail");
		DataSourceTextField imageUrl = new DataSourceTextField("imageUrl");
		DataSourceTextField name = new DataSourceTextField("name");
		DataSourceTextField geoLocation = new DataSourceTextField("geoLocation");
		DataSourceIntegerField commentCount = new DataSourceIntegerField("commentCount");

		setFields(imageId, thumbnail, imageUrl, name, geoLocation, commentCount);
		setClientOnly(true);
	}

	public static ImageDataSource getInstance() {
		if (instance == null) {
			instance = new ImageDataSource(SC.generateID());
		}
		return instance;
	}
}
